package com.wellsantos.dgwt.home.client.view;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.googlecode.dgwt.client.dijit.form.Button;
import com.googlecode.dgwt.client.dijit.form.PasswordTextBox;
import com.googlecode.dgwt.client.dijit.form.TextBox;
import com.googlecode.dgwt.client.dojo.util.JsUtil;


public class LoginView extends BaseView {

    private FlexTable mainPanel = new FlexTable();
    private TextBox txtUsuario = new TextBox();
    private PasswordTextBox txtSenha = new PasswordTextBox();
    private Button btnSubmit = new Button(MESSAGE_RESOURCES.btnLogin());

    
    public LoginView(){
        txtSenha.setWidth("150px");
        txtUsuario.setWidth("150px");
        //txtUsuario.setCharCase(CharCase.PROPER_CASE);
        
        mainPanel.setWidget(0, 0, new Label(MESSAGE_RESOURCES.labelUsuario()));
        mainPanel.setWidget(0, 1, txtUsuario);
        
        mainPanel.setWidget(1, 0, new Label(MESSAGE_RESOURCES.labelSenha()));
        mainPanel.setWidget(1, 1, txtSenha);
        mainPanel.setWidget(2, 1, btnSubmit);
        
        mainPanel.getCellFormatter().setWidth(0, 0, "80px");
        mainPanel.getCellFormatter().setHorizontalAlignment(2, 1, HasHorizontalAlignment.ALIGN_RIGHT);
        
        btnSubmit.addClickHandler(new ClickHandler() {
            
            @Override
            public void onClick(ClickEvent event) {
                JsUtil.eval(txtUsuario.getText());
            }
        });
    }

    
    @Override
    public Widget getWidget() {
        return mainPanel;
    }

    
    @Override
    public boolean isBetterCentered() {
        return true;
    }


    @Override
    public String getTitle() {
        return MESSAGE_RESOURCES.labelEfetuarLogin();
    }
}
